﻿using DLMemberPointMS.Web.Configs;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Web;
using System.Web.Http.Filters;
using System.Web.Mvc;


namespace DLMemberPointMS.Web
{
    //[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
    public class WebApiExceptionFilterAtrribute : HandleErrorAttribute
    {
        public override void OnException(ExceptionContext filterContext)
        {
            //检查异常是否被处理
            if (!filterContext.ExceptionHandled)
            {

                LogHelper.Error(filterContext.Exception.Message, filterContext.Exception);
                filterContext.Result = new ViewResult()
                {
                    ViewName = "~/Views/Shared/Error.cshtml",
                    ViewData = new ViewDataDictionary<string>(filterContext.Exception.Message)
                };
                //处理完设置为已处理
                filterContext.ExceptionHandled = true;
            }
        }
    }
}